﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Expect.Vs2008.Extensions.LanguageService
{
    public class Error : IComparable<Error>
    {
        internal const int minErr = 50;
        internal const int minWrn = 100;

        public string message;
        public int line;
        public int column;
        public int length;
        public bool isWarn;

        internal Error(string msg, int lin, int col, int len, bool warningOnly)
        {
            isWarn = warningOnly;
            message = msg;
            line = lin;
            column = col;
            length = len;
        }

        public int CompareTo(Error r)
        {
            if (this.line < r.line) return -1;
            else if (this.line > r.line) return 1;
            else if (this.column < r.column) return -1;
            else if (this.column > r.column) return 1;
            else return 0;
        }

        public bool Equals(Error r)
        {
            return (this.line == r.line && this.column == r.column);
        }

        public void Report()
        {
            Console.WriteLine("Line " + line + ", column  " + column + ": " + message);
        }
    }
}
